<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //声明变量接收用户的值
        /*   let num = prompt('请输入一个数字');
          if (num < 10) {
              alert('0' + num);
              console.log('0' + num);
          } else {
              console.log(num);
          } */
        //三元写法
        let num1 = 2;
        num1 = (num1 < 10) ? '0' + num1 : num1;
        console.log(num1);
    </script>
</body>

</html>